home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 3006 / 3006.xpi / chrome / dwhelper.jar / content / comment.xul < prev    next >
Extensible Markup Language  |  2010-01-15  |  6KB  |  219 lines

  1. <?xml version="1.0"?> 
  2. <!-- *****************************************************************************
  3.  *            Copyright (c) 2006-2009 Michel Gutierrez. All Rights Reserved.
  4.  ****************************************************************************** -->
  5. <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
  6. <?xml-stylesheet href="chrome://dwhelper/skin/dwhelper.css" type="text/css"?>
  7. <?xml-stylesheet href="chrome://dwhelper/content/bindings.css" type="text/css"?>
  8.  
  9. <!DOCTYPE window SYSTEM "chrome://dwhelper/locale/dwhelper.dtd" >
  10.  
  11. <window id="dwhelper-comment"
  12.         title="&title.comment;"
  13.         flex="1"
  14.         onload="onLoad()"
  15.         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  16.         xmlns:html="http://www.w3.org/1999/xhtml"
  17.         persist="screenX screenY"
  18.         >
  19.  
  20.     <script type="application/x-javascript"
  21.         src="chrome://dwhelper/content/dwhutil.js" />
  22.  
  23.     <script><![CDATA[
  24.  
  25. var Util=Components.classes["@downloadhelper.net/util-service;1"]
  26.     .getService(Components.interfaces.dhIUtilService);
  27.  
  28. var datasource=null;
  29. var siteres=null;
  30.  
  31. function onLoad() {
  32.     
  33.     var props=window.arguments[0].QueryInterface(Components.interfaces.nsIProperties);
  34.     datasource=props.get("datasource",Components.interfaces.nsIRDFDataSource);
  35.     siteres=props.get("siteres",Components.interfaces.nsIRDFResource);
  36.     var siteName=Util.getPropertyValueRS(datasource,siteres,"http://downloadhelper.net/dwhelper/1.0#name");
  37.     document.getElementById("dwhelper-site-name").setAttribute("value",siteName);
  38.  
  39.     var x=document.documentElement.getAttribute("screenX");
  40.     var y=document.documentElement.getAttribute("screenY");
  41.     window.moveTo(x,y);
  42.  
  43.     document.getElementById("author").focus();
  44.  
  45. }
  46.  
  47. function submitComment() {
  48.     var siteId=Util.getPropertyValueRS(datasource,siteres,"http://downloadhelper.net/dwhelper/1.0#id");
  49.     var authorField=document.getElementById("author");
  50.     var titleField=document.getElementById("title");
  51.     var ratingField=document.getElementById("rating");
  52.     var commentField=document.getElementById("comment");
  53.     var tagsField=document.getElementById("tags");
  54.     
  55.     var author=authorField.value;
  56.     if(author.length==0) {
  57.         Util.alertError(Util.getText("error.comment.author-too-short"));
  58.         authorField.focus();
  59.         return;
  60.     }
  61.     var title=titleField.value;
  62.     if(title.length==0) {
  63.         Util.alertError(Util.getText("error.comment.title-too-short"));
  64.         titleField.focus();
  65.         return;
  66.     }
  67.     var rating=ratingField.value;
  68.     if(rating=="-1") {
  69.         Util.alertError(Util.getText("error.comment.no-rating"));
  70.         ratingField.focus();
  71.         return;
  72.     }
  73.     var comment=commentField.value;
  74.     if(comment.length<12) {
  75.         Util.alertError(Util.getText("error.comment.comment-too-short"));
  76.         commentField.focus();
  77.         return;
  78.     }
  79.     var tags=tagsField.value;
  80.     
  81.     var obj={
  82.         siteid: siteId,
  83.         author: author,
  84.         authorid: Util.getProfileDir().leafName,
  85.         title: title,
  86.         comment: comment,
  87.         rating: rating,
  88.         tags: tags
  89.     };
  90.     
  91.     var body=DWHUtil.urlEncodeObject(obj);
  92.         
  93.     var cb=function(status,req,args) {
  94.         if(status==false) {
  95.             Util.alertError(Util.getText("error.create-comment.connection"));
  96.         } else {
  97.             var succeed=Util.xpGetString(req.responseXML.documentElement,"succeed");
  98.             if(succeed=="true") {
  99.                 //Util.alertWarning(Util.getText("message.create-comment.success"));
  100.             } else {
  101.                 var errMsg=Util.xpGetString(req.responseXML.documentElement,"error");
  102.                 Util.alertError(Util.getText(errMsg));
  103.             }
  104.         }
  105.         window.close();
  106.         window.location="about:blank"; // to finish closing on window
  107.     }
  108.     
  109.     DWHUtil.loadAsync("http://www.downloadhelper.net/create-comment.php",cb,{ window: window },body,"POST", 
  110.         { contentType: "application/x-www-form-urlencoded" });
  111.         
  112.     //document.getElementById("deck").selectedIndex=1;
  113.     document.getElementById("main-panel").setAttribute("hidden","true");
  114.     document.getElementById("dwhelper-wait-panel").setAttribute("hidden","false");
  115.     setTimeout(function() {window.sizeToContent();},0);
  116. }
  117.  
  118. ]]>
  119.     </script>
  120.     
  121.     <vbox>
  122.     
  123.     <vbox id="main-panel">
  124.                 
  125.         <groupbox>
  126.             <caption label="&caption.comment.comment;"/>
  127.             
  128.             <grid id="dwhelper-add-comment">
  129.                 <columns>
  130.                     <column/>
  131.                     <column flex="1"/>
  132.                 </columns>
  133.                 <rows>
  134.                     <row>
  135.                         <label value="&label.comment.site;"/>
  136.                         <label id="dwhelper-site-name"/>
  137.                     </row>
  138.                     <row>
  139.                         <label value="&label.comment.author;"/>
  140.                         <vbox>
  141.                             <textbox id="author"/>
  142.                             <description>&help.comment.author;</description>
  143.                         </vbox>
  144.                     </row>
  145.                     <row>
  146.                         <label value="&label.comment.title;"/>
  147.                         <vbox>
  148.                             <textbox id="title"/>
  149.                             <description>&help.comment.title;</description>
  150.                         </vbox>
  151.                     </row>
  152.                     <row>
  153.                         <label value="&label.comment.rating;"/>
  154.                         <vbox>
  155.                             <hbox>
  156.                                 <menulist id="rating" label="" value="">
  157.                                     <menupopup>
  158.                                         <menuitem label="--" value="-1"/>
  159.                                         <menuitem label="0" value="0"/>
  160.                                         <menuitem label="1" value="1"/>
  161.                                         <menuitem label="2" value="2"/>
  162.                                         <menuitem label="3" value="3"/>
  163.                                         <menuitem label="4" value="4"/>
  164.                                         <menuitem label="5" value="5"/>
  165.                                     </menupopup>
  166.                                 </menulist>
  167.                                 <spacer flex="1"/>
  168.                             </hbox>
  169.                             <description>&help.comment.rating;</description>
  170.                         </vbox>
  171.                     </row>
  172.                     <row>
  173.                         <label value="&label.comment.comment;"/>
  174.                         <vbox>
  175.                             <textbox id="comment" multiline="true" rows="5"/>
  176.                             <description>&help.comment.comment;</description>
  177.                         </vbox>
  178.                     </row>
  179.                     <row>
  180.                         <label value="&label.comment.tags;"/>
  181.                         <vbox>
  182.                             <textbox id="tags"/>
  183.                             <description>&help.comment.tags;</description>
  184.                         </vbox>
  185.                     </row>
  186.                 </rows>
  187.             </grid>
  188.  
  189.             <hbox class="dwhelper-button-line">
  190.                 <spacer flex="1"/>
  191.                 <button label="&button.comment.submit;" oncommand="submitComment()"/>
  192.                 <button label="&button.comment.close;" oncommand="window.close()"/>
  193.             </hbox>
  194.  
  195.         </groupbox>
  196.             
  197.     </vbox>
  198.     
  199.     <vbox id="dwhelper-wait-panel" hidden="true">
  200.         <spacer flex="1"/>
  201.         <hbox>
  202.             <spacer flex="1"/>
  203.             <label value="&label.comment.wait;"/>
  204.             <spacer flex="1"/>
  205.         </hbox>
  206.         <spacer flex="1"/>
  207.         <hbox>
  208.             <spacer flex="1"/>
  209.             <image class="waiter" src="chrome://dwhelper/skin/dwhelper24-anim.gif"/>
  210.             <spacer flex="1"/>
  211.         </hbox>
  212.         <spacer flex="1"/>
  213.     </vbox>
  214.     
  215.     
  216.     </vbox>
  217.  
  218. </window>
  219.